<%@ page import="java.util.*,com.release.utils.*,java.text.*,java.io.*,com.release.bean.*" %>
<%

try {
	 session = request.getSession();
  /*
  if (session.getAttribute("USER_ID") == null || !((String) session.getAttribute("SESSION_ID")).equals(session.getId())) {

	
				try {
					response.sendRedirect("LoginPage.jsp");
				} catch (IOException ioe) {
					ioe.printStackTrace();
				}


	
			}
			
		
			else
*/

	{
		Vector ReleaseReportVector = null;	
		Vector FilterVector = null;
		String usergroupname = (String)session.getAttribute("USER_GROUP_NAME"); 
		//DBUtil dbutil = new DBUtil(getServletContext());
		DBUtil dbutil = new DBUtil();
		ReleaseUtil releaseUtil = new ReleaseUtil();
		String userid = (String)session.getAttribute("USER_ID")==null?"":(String)session.getAttribute("USER_ID");
		userid= "joju.varghese@cgi.com";
		String getreport = (String)request.getParameter("getreportbutton")==null?"":request.getParameter("getreportbutton");
		String releaseName = (String)request.getParameter("releaseName")==null?(request.getParameter("hiddenrelname")==null?"":request.getParameter("hiddenrelname")):request.getParameter("releaseName");
		String filterreportbutton = (String)request.getParameter("filterreportbutton")==null?"":request.getParameter("filterreportbutton");

			System.out.println(">>>>>> filterreportbutton :"+filterreportbutton);
			filterreportbutton="Get Filter Report";

			//ReleaseReportVector =(Vector) session.getAttribute("RELEASE_FILTER_REPORT");

					String ftr_dbname = (String)request.getParameter("ftr_dbname")==null?"0":request.getParameter("ftr_dbname");
					String ftr_objtype = (String)request.getParameter("ftr_objtype")==null?"0":request.getParameter("ftr_objtype");
					String ftr_user = (String)request.getParameter("ftr_user")==null?"0":request.getParameter("ftr_user");
			if(getreport.equals("Get Report")){
					ReleaseReportVector = dbutil.getReleaseReport(releaseName);
					
					}


					if(filterreportbutton.equals("Get Filter Report") ){
					
					System.out.println(">>>>>> releaseName :"+releaseName+":"+ftr_dbname+":"+ftr_objtype+":"+ftr_user);
					//FilterVector = dbutil.getFilterReport(releaseName, ftr_dbname, ftr_objtype, ftr_user);
					ReleaseReportVector = releaseUtil.getFilterReport(releaseName, ftr_dbname, ftr_objtype, ftr_user);

					
					}

%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>


			function checkForRelease(obj){
			
			 if( obj.value == 0){
					alert("Kindly select Release Name from the list.");
					obj.focus();
					return false;
				 }

				 document.searchReleaseReport.action="ReleaseLog.jsp";
				 document.searchReleaseReport.filterreportbutton.value="Get Filter Report";
				 alert('checkForRelease()');
				 document.searchReleaseReport.submit();
				
			}

			function exportToExcelForCR(relName)
				{
					document.FilterReportDisplayForm.action = "ExportToExcelForCRNotes.jsp";	
					document.FilterReportDisplayForm.submit();
					document.FilterReportDisplayForm.action = "ReleaseLog.jsp";
			 	}
				
			function submitThisForReport()
				{
					document.searchReleaseReport.releaseName.value = document.FilterReportDisplayForm.hiddenrelname.value
					document.searchReleaseReport.filterreportbutton.value = "Get Filter Report";
					document.searchReleaseReport.submit();
					document.FilterReportDisplayForm.submit();
				}

			function exportToExcelForFilter()
				{
					document.FilterReportDisplayForm.action = "ExportToExcelForFilter.jsp";	
					document.FilterReportDisplayForm.submit();
					document.FilterReportDisplayForm.action = "ReleaseLog.jsp";
				}
			function exportToExcelForDBA()
				{
					document.ReleaseDBAReportDisplay.action = "ExportToExcelForDBA.jsp";	
					document.ReleaseDBAReportDisplay.submit();
					document.ReleaseDBAReportDisplay.action = "ReleaseLog.jsp";
				}	


			function trim(sString)
				  {
					sTrimmedString = "";
				    if (sString != "") {
					  var iStart = 0;
					  var iEnd = sString.length - 1;
					  // var sWhitespace = " \t\f\n\r\v";
					  var sWhitespace = "   ";
		
		
					  while (sWhitespace.indexOf(sString.charAt(iStart)) != -1) {
						 iStart++;
						 if (iStart > iEnd) 
							break;
					  }

					  // If the string not just whitespace
					  if (iStart <= iEnd) {
						 while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
							iEnd--;
							 sTrimmedString = sString.substring(iStart,++iEnd);
						  }
					   }
				   return sTrimmedString;
				 }

		  function checkforempty()
			{
			
				document.ReleaseExecuteForm.unixServerForRel.value =trim(document.ReleaseExecuteForm.unixServerForRel.value);
				document.ReleaseExecuteForm.unixServerUserid.value =trim(document.ReleaseExecuteForm.unixServerUserid.value);
				document.ReleaseExecuteForm.unixServerPwd.value =trim(document.ReleaseExecuteForm.unixServerPwd.value);
			
			
				if(submitForms(document.ReleaseExecuteForm.unixServerForRel, document.ReleaseExecuteForm.unixServerUserid, document.ReleaseExecuteForm.unixServerPwd))
				{
					document.ReleaseExecuteForm.Act.value = "Execute Shell for Release";
					document.ReleaseExecuteForm.submit();
				}
				
			}


			function checkforempty2()
			{
			
				document.ReleaseExecuteForm.unixServerForRel.value =trim(document.ReleaseExecuteForm.unixServerForRel.value);
				document.ReleaseExecuteForm.unixServerUserid.value =trim(document.ReleaseExecuteForm.unixServerUserid.value);
				document.ReleaseExecuteForm.unixServerPwd.value =trim(document.ReleaseExecuteForm.unixServerPwd.value);
			
			
				if(submitForms(document.ReleaseExecuteForm.unixServerForRel, document.ReleaseExecuteForm.unixServerUserid, document.ReleaseExecuteForm.unixServerPwd))
				{
					document.ReleaseExecuteForm.Act.value = "Get Log for Release";
					document.ReleaseExecuteForm.submit();
				}
				
			}


			function submitForms(obj1, obj2, obj3){
	
			    if (obj1.value.length == 0 ){
					alert("Please enter unix server name.");
					obj1.focus();
					return false;
				 }

				 if( obj2.value.length == 0){
					alert("Please enter unix server userid.");
					obj2.focus();
					return false;
				 }

				 if( obj3.value.length == 0){
					alert("Please enter unix server password.");
					obj3.focus();
					return false;
				}
			
				return true;
				//  document.updateRelease.submit();
				//  document.searchReleaseForm.submit();
	
				//document.displayForm.submit();
		  	
		  				//  document.MainForm.submit();
						//alert("HIIIIIII");
			}
		
		function overviewCRDetails(ReleaseObjKey) {
			dwin=window.open("OverviewCRDetail.jsp?relobjkey="+ReleaseObjKey,"detailWin","width=900,height=600,scrollbars=yes,resizable=yes");
			dwin.focus();
		
		}
		</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Sql Script</title>
<style type="text/css">
<!--
body {
	background-image: url(../images/bg/pagebg.gif);
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link href="joju.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style4 {color: #FFFFFF}
-->
</style>
</head>


<body onload="MM_preloadImages('../images/menu2_01.jpg','../images/menu2_02.jpg','../images/menu2_03.jpg','../images/menu2_04.jpg','../images/menu2_05.jpg','../images/menu2_06.jpg','../images/menu2_07.jpg ','../images/menu2_08.jpg')">
<form name="searchReleaseReport" method="post" >
<center>
  <table id="Table_01" width="1002" height="778" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td height="101" align="left" valign="top"><img src="../images/index_01.jpg" width="1002" height="101" alt="" /></td>
    </tr>
	<tr>
      <td height="46" align="left" valign="top"><table id="Table_3" width="1002" height="46" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td><a href="newtree.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image22','','../images/menu2_01.jpg',1)"><img src="../images/menu_01.jpg" alt="home" name="Image22" width="82" height="46" border="0" id="Image22" /></a></td>
            <td><a href="Data.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image23','','../images/menu2_02.jpg',1)"><img src="../images/menu_02.jpg" alt="tracker" name="Image23" width="83" height="46" border="0" id="Image23" /></a></td>
            <td><a href="ReleaseLog.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image24','','../images/menu2_03.jpg',1)"><img src="../images/menu_03.jpg" alt="documents" name="Image24" width="83" height="46" border="0" id="Image24" /></a></td>
            <td><a href="ReleaseLog.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image27','','../images/menu2_06.jpg',1)"><img src="../images/menu_06.jpg" alt="File Release" name="Image27" width="83" height="46" border="0" id="Image27" /></a></td>   
			<td><a href="ReleaseLog.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image28','','../images/menu2_07.jpg ',1)"><img src="../images/menu_07.jpg" alt="wiki" name="Image28" width="83" height="46" border="0" id="Image28" /></a></td>
            <td><a href="buldandtest.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image29','','../images/menu2_08.jpg',1)"><img src="../images/menu_08.jpg" alt="build and test" name="Image29" width="84" height="46" border="0" id="Image29" /></a></td>
            <td><img src="../images/menu_09.jpg" width="333" height="46" alt="" /></td>
            <td><img src="../images/menu_10.jpg" width="5" height="46" alt="" /></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td height="631" align="left" valign="top"><table id="Table_" width="1002" height="595" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="2" bgcolor="#A1C0DF"><img src="../images/content_01.jpg" width="226" height="1" alt="" /></td>
            <td><img src="../images/content_02.jpg" width="776" height="1" alt="" /></td>
          </tr>
          <tr>
            <td height="574" valign="top" bgcolor="#A1C0DF">&nbsp;</td>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="835" colspan="5" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="3%">&nbsp;</td>
                      <td width="97%">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td><table id="Table_2" width="736" height="251" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="11"><img src="../images/login_01.jpg" width="11" height="11" alt="" /></td>
                          <td width="713" background="../images/login_02.jpg"><img src="../images/login_02.jpg" width="384" height="11" alt="" /></td>
                          <td width="12"><img src="../images/login_03.jpg" width="12" height="11" alt="" /></td>
                        </tr>
                        <tr>
                          <td background="../images/login_02.jpg"><img src="../images/login_04.jpg" width="11" height="224" alt="" /></td>
                          <td align="left" valign="top" background="../images/bg/loginbg.jpg">
						<input type=hidden name=hiddenrelname value='<%=releaseName%>'>
						<table cellspacing="0" cellpadding="0" width="95%" 
                          border="0">
                            <tbody>
                              <tr class="style2">
                                <td class="marginscontact"><span class="contentbold1">Log Basic Details<br />
                                  <br />
                                </span></td>
                                <td class="marginscontact">&nbsp;</td>
                                <td class="marginscontact">&nbsp;</td>
                              </tr>
                              <tr class="style2">
                                <td class="marginscontact" width="44%"><div align="right"><span class="normalcontent"><span class="content">Release Name</span> <span 
                              class="photo_name">:</span></span></div></td>
                                <td class="marginscontact" width="3%">&nbsp;</td>
                                <td class="marginscontact" width="53%">
								
								<select name=releaseName  >
								
													
								<% 															
									Vector relNameVector = dbutil.getReleaseName(userid);
									for(int i=0;i<relNameVector.size();i++)
									{
										ReleaseVO relbean =(ReleaseVO)relNameVector.elementAt(i); 
								%>
	
										<option value= '<%=	relbean.getReleaseName()%>'> 									
										<%= relbean.getReleaseName()%> 
										</option>
					
								<%	}
								%>
								</select>
								
								</td>
                              </tr>
                              
					
					<table cellpadding="0" cellspacing="1" width="100%" style="BORDER:#000000 1px solid" colspan=8>
										<input type=hidden name=hiddenrelname value='<%=releaseName%>'>
										<input type=hidden name=filterAction value="FilterAction">
						log are here					
					</table>


		
					  </td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td></td>
                    </tr>
                  </table>

                    <br />
                      <br />
                      <br />
                    <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br /></td>
                </tr>
                
            </table></td>
          </tr>
          <tr>
            <td height="19" colspan="2" valign="top" bgcolor="#CCCCCC"><span class="contentwhitesatheesh">&copy;2010 Joju's Software. All rights reserved.</span></td>
          </tr>
      </table></td>
    </tr>
  </table>
</center>
</form>
</body>
</html>
<% 
}
}
catch(Exception e) {
				e.printStackTrace();
		}

		%>